package ar.cpfw.hibernate.mapping.onetoone;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Parameter;

@Entity
@Table(name = "malcolm")
public class Malcolm {

	@Id
	@GeneratedValue(generator = "foreing")
	@org.hibernate.annotations.GenericGenerator(name = "foreing", strategy = "foreign", 
		parameters = @Parameter(name = "property", value = "angus"))
	@Column(name = "id")
	private String id;

	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@PrimaryKeyJoinColumn
	private Angus angus;

	public void setAngus(Angus angus) {
		this.angus = angus;
	}

	public Angus getAngus() {
		return this.angus;
	}

	public Malcolm() {

	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}
